package P1100;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-10-10 14:22
 */
public class P1149_火柴棒等式 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.close();
        invoke(n-4);
    }

    private static int res = 0;

    private static class Node implements Comparable<Node>{
        int val;
        int index;
        public Node(int val,int index){
            this.val = val;
            this.index = index;
        }
        @Override
        public int compareTo(Node o) {
            return this.val-o.val;
        }
    }

    private static void invoke(int n) {
        if(n < 8) {
            System.out.println(0);
            return ;
        }
        int[] hash = new int[]{6,2,5,5,4,5,6,3,7,6};
        List<Node> temp = new ArrayList<>();
        for(int i=1;i<1000;++i){
            int now = i;
            int count = 0;
            while(now>0){
                count += hash[now%10];
                now /= 10;
            }
            if(count <= n) {
                temp.add(new Node(count, i));
            }
        }
        temp.add(new Node(6,0));
        Node[] nodes = new Node[temp.size()];
        int index = 0;
        for(Node node:temp) nodes[index++] = node;
        Arrays.sort(nodes);
        dfs(1,new int[3],n,nodes);
        System.out.println(res);
    }

    private static void dfs( int now,int[] sum,int total, Node[] nodes) {
        for(int i=0;i<nodes.length;++i){
            if(now == 3){
                sum[2] = i;
                int before = nodes[sum[0]].val+nodes[sum[1]].val;
                if(before > total) return ;//剪枝
                if(nodes[sum[0]].index+nodes[sum[1]].index == nodes[i].index
                        && nodes[sum[0]].val+nodes[sum[1]].val+nodes[sum[2]].val == total){//火柴数目相等并且等式也成立
                    ++res;
//                    System.out.printf("%d+%d = %d\n",nodes[sum[0]].index,nodes[sum[1]].index,nodes[sum[2]].index);
                }
            }else {
                if(now == 1){
                    sum[0] = i;
                }else{
                    sum[1] = i;
                }
                dfs(now+1,sum,total,nodes);
            }
        }
    }


}
